package com.kly.user.db.dao.impl;

import cn.hutool.core.date.DateUtil;
import com.alibaba.excel.util.StringUtils;
import com.fqgj.common.api.Page;
import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.common.utils.CollectionUtils;
import com.fqgj.log.factory.LogFactory;
import com.fqgj.log.interfaces.Log;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.jsoniter.output.JsonStream;
import com.kly.user.db.dao.UserDao;
import com.kly.user.db.dbo.MemberBenefitsDBO;
import com.kly.user.db.dbo.UserDBO;
import com.kly.user.db.entity.CustomUserEntity;
import com.kly.user.db.entity.IssueUserPoolEntity;
import com.kly.user.db.entity.UserEntity;
import com.kly.user.enums.AppCodeEnum;
import com.kly.user.enums.GenderEnum;
import com.kly.user.enums.UserStatus;
import com.kly.user.enums.UserType;
import org.springframework.stereotype.Repository;

import java.util.*;

/**
 * User: yujianfu
 * Date: 2023-05-22
 * Time: 10:46:07.389
 */

@Repository
public class UserDaoImpl extends AbstractBaseMapper<UserEntity> implements UserDao {
    public static Log logger = LogFactory.getLog(UserDaoImpl.class);
    @Override
    public UserEntity selectByUserCode(String userCode) {
        return getSqlSession().selectOne(this.getStatement("selectByCode"), userCode);
    }

    @Override
    public UserEntity selectOne(String appCode, String identity) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("appCode", appCode);
        params.put("identity", identity);
        return getSqlSession().selectOne(this.getStatement("selectOne"), params);
    }

    @Override
    public UserEntity selectActiveUser(String userCode) {
        return getSqlSession().selectOne(this.getStatement("selectActiveUser"), userCode);
    }

    @Override
    public List<UserEntity> selectAllChatter() {
        return getSqlSession().selectList(this.getStatement("selectAllChatter"));
    }


    @Override
    public int update(UserEntity user) {
        return getSqlSession().update(this.getStatement("updateByUserCode"), user);
    }

    @Override
    public int updateOnline(String userCode, Integer online) {
        final HashMap<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("online", online);
        return getSqlSession().update(this.getStatement("updateOnline"), params);
    }

    @Override
    public int delete(String userCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCode", userCode);
        return getSqlSession().update(this.getStatement("deleteByUserCode"), params);
    }

    @Override
    public Integer offlineByUserCodeList(Set<String> set) {
        return getSqlSession().update(this.getStatement("offlineByUserCodeList"), set);
    }

    @Override
    public Integer onlineByUserCodeList(Set<String> set) {
        return getSqlSession().update(this.getStatement("onlineByUserCodeList"), set);
    }

    @Override
    public List<UserEntity> queryAppAccounts() {

        Map<String, Object> params = Maps.newHashMap();
        params.put("userType", UserType.NORMAL_USER.getType());
        params.put("status", UserStatus.ACTIVE.getType());
        params.put("deleted", 0);
        return this.selectByParams(params);
    }

    /**
     * 查询推荐用户
     *
     * @param params 需要排除的用户
     * @return
     */
    @Override
    public List<UserEntity> queryRecommendUsers(Map<String, Object> params) {
        return this.getSqlSession().selectList(this.getStatement("queryRecommendUsers"), params);
    }

    @Override
    public List<UserEntity> selectUsers(Map<String, Object> params) {
        return this.getSqlSession().selectList(this.getStatement("selectUsers"), params);
    }

    @Override
    public List<UserEntity> listUsers(List<String> userCodes) {
        if (CollectionUtils.isEmpty(userCodes)) {
            return Lists.newArrayList();
        }
        final HashMap<String, Object> params = Maps.newHashMap();
        params.put("list", userCodes);
        return this.getSqlSession().selectList(this.getStatement("listUsers"), params);
    }

    @Override
    public List<UserEntity> selectWlmUsers(String userCode, Integer filterUserType, Page page) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("filterUserType", filterUserType);
        params.put("offset", page.getStartIndex());
        params.put("limit", page.getPageSize());
        return this.getSqlSession().selectList(this.getStatement("selectWlmUsers"), params);
    }

    @Override
    public List<UserEntity> selectLikeUsers(String userCode, Page page) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("offset", page.getStartIndex());
        params.put("limit", page.getPageSize());
        return this.getSqlSession().selectList(this.getStatement("selectLikeUsers"), params);
    }

    @Override
    public List<UserEntity> queryMatchUsers(Map<String, Object> params) {
        return this.getSqlSession().selectList(this.getStatement("queryMatchUsers"), params);
    }

    @Override
    public void updateOnlineTimeStamp(List<String> userCodes) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCodes", userCodes);
        params.put("onlineTimestamp", Long.valueOf(Calendar.getInstance().getTimeInMillis()).toString());
        getSqlSession().update(this.getStatement("updateOnlineTimeStamp"), params);
    }

    @Override
    public void updateOnlineStatus(List<String> userCodes, Integer onlineStatus) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCodes", userCodes);
        params.put("onlineStatus", onlineStatus);
        getSqlSession().update(this.getStatement("updateOnlineStatus"), params);
    }

    /**
     * 查询推荐用户
     *
     * @param filterUsers 需要排除的用户
     * @param recordNum   查询条数
     * @param lookingFor  性向
     * @param userType    用户类型
     * @param online      在线状态
     * @return
     */
    @Override
    public List<UserEntity> queryRecommendUsers(String userCode, List<String> filterUsers, Integer recordNum, Integer lookingFor, Integer userType, Integer online) {
        Map<String, Object> params = Maps.newHashMap();
        if (CollectionUtils.isNotEmpty(filterUsers)) {
            params.put("list", filterUsers);
        }
        params.put("userCode", userCode);
        params.put("recordNum", recordNum);
        // 性向如果为未知，查询全部用户数据
        if (GenderEnum.UNKNOWN.getType() != lookingFor) {
            params.put("lookingFor", lookingFor);
        }
        if (Objects.nonNull(userType)) {
            params.put("userType", userType);
        }
        if (Objects.nonNull(online)) {
            params.put("online", online);
        }

        return this.getSqlSession().selectList(this.getStatement("queryRecommendUsers"), params);
    }

    @Override
    public List<UserEntity> queryFCRecommendUsers(String userCode, List<String> filterUsers, Integer recordNum, Integer lookingFor, Integer userType, Integer online) {
        Map<String, Object> params = Maps.newHashMap();
        if (CollectionUtils.isNotEmpty(filterUsers)) {
            params.put("list", filterUsers);
        }
        params.put("userCode", userCode);
        params.put("recordNum", recordNum);
        // 性向如果为未知，查询全部用户数据
        if (GenderEnum.UNKNOWN.getType() != lookingFor) {
            params.put("lookingFor", lookingFor);
        }
        if (Objects.nonNull(userType)) {
            params.put("userType", userType);
        }
        if (Objects.nonNull(online)) {
            params.put("online", online);
        }

        return this.getSqlSession().selectList(this.getStatement("queryFCRecommendUsers"), params);

    }

    @Override
    public List<UserEntity> getUsersByUserType(Integer type) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("type", type);
        return this.getSqlSession().selectList(this.getStatement("getUsersByUserType"), params);

    }

    @Override
    public List<UserEntity> listUsersByUserType(Integer type, Page page) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("type", type);
        params.put("page", page);
        return this.getSqlSession().selectList(this.getStatement("listUsersByUserType"), params);
    }

    @Override
    public Integer getUsersByUserTypeCnt(Integer type) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("type", type);
        return this.getSqlSession().selectOne(this.getStatement("getUsersByUserTypeCnt"), params);
    }

    @Override
    public List<UserEntity> getUsersByUserTypeAndOnlineStatus(Integer type, Integer online) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("type", type);
        params.put("online", online);
        return this.getSqlSession().selectList(this.getStatement("getUsersByUserTypeAndOnlineStatus"), params);

    }

    @Override
    public List<CustomUserEntity> queryHomePageData(String userCode, List<String> filterUsers, Integer recordNum, Integer lookingFor, Integer userType, Integer online) {
        Map<String, Object> params = Maps.newHashMap();
        if (CollectionUtils.isNotEmpty(filterUsers)) {
            params.put("list", filterUsers);
        }
        params.put("userCode", userCode);
        params.put("recordNum", recordNum);
        // 性向如果为未知，查询全部用户数据
        if (GenderEnum.UNKNOWN.getType() != lookingFor) {
            params.put("lookingFor", lookingFor);
        }
        if (Objects.nonNull(userType)) {
            params.put("userType", userType);
        }
        if (Objects.nonNull(online)) {
            params.put("online", online);
        }

        return this.getSqlSession().selectList(this.getStatement("queryHomePageData"), params);

    }

    @Override
    public List<UserEntity> getAllModels() {
        Map<String, Object> params = new HashMap<>();
        return getSqlSession().selectList(this.getStatement("getAllModels"), params);
    }

    @Override
    public List<UserEntity> getAllModelsAssignedChatter(Integer onlineStatus) {
        Map<String, Object> params = new HashMap<>();
        params.put("onlineStatus", onlineStatus);
        return getSqlSession().selectList(this.getStatement("getAllModelsAssignedChatter"), params);
    }

    @Override
    public List<UserEntity> getAllModelsByChatterUserCode(String chatterUserCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("chatterUserCode", chatterUserCode);
        return getSqlSession().selectList(this.getStatement("getAllModelsByChatterUserCode"), params);
    }

    @Override
    public List<UserEntity> getAllModelsNotAssignedChatter(Integer onlineStatus) {
        Map<String, Object> params = new HashMap<>();
        params.put("onlineStatus", onlineStatus);
        return getSqlSession().selectList(this.getStatement("getAllModelsNotAssignedChatter"), params);
    }

    @Override
    public List<UserEntity> getCustomerLikedModelListByCustomerUserCode(String customerUserCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("customerUserCode", customerUserCode);
        return getSqlSession().selectList(this.getStatement("getCustomerLikedModelListByCustomerUserCode"), params);
    }

    @Override
    public MemberBenefitsDBO memberUsageDetail(String userCode, Integer days) {
        final HashMap<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("startDate", DateUtil.beginOfDay(new Date()));
        params.put("endDate", DateUtil.endOfDay(new Date()));
        return getSqlSession().selectOne(this.getStatement("memberUsageDetail"), params);
    }

    @Override
    public List<UserEntity> queryUsers(Map<String, Object> params, Page page) {
        params.put("page", page);
        if (params.containsKey("account")) {
            params.put("account", params.get("account"));
        }

        if (params.containsKey("nickName")) {
            params.put("nickName", params.get("nickName"));
        }

        if (params.containsKey("userType")) {
            params.put("userType", params.get("userType"));
        }

        if (params.containsKey("onlineStatus")) {
            params.put("onlineStatus", params.get("onlineStatus"));
        }

        if (params.containsKey("userCode")) {
            params.put("userCode", params.get("userCode"));
        }

        if (params.containsKey("assignedChatter")) {
            params.put("assignedChatter", params.get("assignedChatter"));
        }

        return getSqlSession().selectList(this.getStatement("queryUsers"), params);
    }

    @Override
    public Boolean isFirstRegister(String clientId, String mobile, String email, String appCode) {
        Map<String, Object> params = Maps.newHashMap();
        // 入参为空时，为N取替代，使查询条件不成立即可
        params.put("clientId", StringUtils.isBlank(clientId) ? "N" : clientId);
        params.put("mobile", StringUtils.isBlank(mobile) ? "N" : mobile);
        params.put("email", StringUtils.isBlank(email) ? "N" : email);
        params.put("appCode", StringUtils.isBlank(appCode) ? AppCodeEnum.MEBOO.getAppCode() : appCode);

        final List<Object> listAccountFromSameUser = this.getSqlSession().selectList(this.getStatement("listAccountFromSameUser"), params);
        if (CollectionUtils.isNotEmpty(listAccountFromSameUser)) {
            return Boolean.FALSE;
        }
        return Boolean.TRUE;
    }

    @Override
    public List<UserEntity> getRegisterDateUser(Date registerDate) {
        Map<String, Object> params = new HashMap<>();
        params.put("registerDate", registerDate);
        return getSqlSession().selectList(this.getStatement("getRegisterDateUser"), params);
    }

    /**
     * 这个是通过比较最近的活跃时间戳来获取用户的
     */
    @Override
    public int getRegisterDateUserCount(String onlineTimestamp) {
        Map<String, Object> params = new HashMap<>();
        params.put("onlineTimestamp", onlineTimestamp);
        return (Integer) getSqlSession().selectOne(this.getStatement("getRegisterDateUserCount"), params);
    }


    @Override
    public List<UserEntity> getRegisterDateUserLimit(String onlineTimestamp, int pageNum) {
        Map<String, Object> params = new HashMap<>();
        params.put("onlineTimestamp", onlineTimestamp);
        params.put("startNum", pageNum * 100);
        return getSqlSession().selectList(this.getStatement("getRegisterDateUserLimit"), params);
    }

    @Override
    public UserEntity queryWLMRecommendUsers(String userCode, Integer lookingFor, Integer member) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        // 性向如果为未知，查询全部用户数据
        if (GenderEnum.UNKNOWN.getType() != lookingFor) {
            params.put("lookingFor", lookingFor);
        }
        params.put("member", member);
        return this.getSqlSession().selectOne(this.getStatement("queryWLMRecommendUsers"), params);
    }

    @Override
    public UserEntity queryLBRecommendUsers(String userCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        return this.getSqlSession().selectOne(this.getStatement("queryLBRecommendUsers"), params);
    }

    @Override
    public List<UserEntity> queryCMOnline() {
        return this.getSqlSession().selectList(this.getStatement("queryCMOnline"));
    }

    @Override
    public List<String> queryIssueUsers(String userCode, int lookingFor, int limitNum) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("limitNum", limitNum);
        // 性向如果为未知，查询全部用户数据
        if (GenderEnum.UNKNOWN.getType() != lookingFor) {
            params.put("lookingFor", lookingFor);
        }
        return this.getSqlSession().selectList(this.getStatement("queryIssueUsers"), params);
    }

    @Override
    public List<String> queryIssueUsersByDistance(String userCode, int lookingFor, String lng, String lat, int recordNum) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("limitNum", recordNum);
        // 性向如果为未知，查询全部用户数据
        if (GenderEnum.UNKNOWN.getType() != lookingFor) {
            params.put("lookingFor", lookingFor);
        }
        params.put("lng", lng);
        params.put("lat", lat);
        return this.getSqlSession().selectList(this.getStatement("queryIssueUsersByDistance"), params);
    }

    @Override
    public String queryLBIssueUsers(String userCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        return this.getSqlSession().selectOne(this.getStatement("queryLBIssueUsers"), params);
    }

    @Override
    public String queryLBIssueUsersByDistance(String userCode, String lng, String lat) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("lng", lng);
        params.put("lat", lat);
        return this.getSqlSession().selectOne(this.getStatement("queryLBIssueUsersByDistance"), params);
    }


    @Override
    public List<UserEntity> queryUserOnline(Integer conversationCount, String chatterCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("conversationCount", conversationCount);
        params.put("chatterCode", chatterCode);
        return this.getSqlSession().selectList(this.getStatement("queryUserOnline"), params);
    }

    @Override
    public List<UserEntity> queryNewUserOnline(Integer conversationCount, Integer limitCount) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("conversationCount", conversationCount);
        params.put("limitCount", limitCount);
        return this.getSqlSession().selectList(this.getStatement("queryNewUserOnline"), params);
    }

    @Override
    public List<String> getOnlineChatterCode() {
        return this.getSqlSession().selectList(this.getStatement("getOnlineChatterCode"));
    }

    @Override
    public String querySupplyRecommendUsers(String userCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("gender", GenderEnum.MAN.getType());
        return this.getSqlSession().selectOne(this.getStatement("querySupplyRecommendUsers"), params);
    }

    @Override
    public List<UserEntity> queryUserOnlineByCreatDate(Date gmtCreate) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("gmtCreate", gmtCreate);
        return this.getSqlSession().selectList(this.getStatement("queryUserOnlineByCreatDate"), params);
    }

    @Override
    public UserEntity getAppflyer(String email, String phone) {
        Map<String, String> params = Maps.newHashMap();
        params.put("email", StringUtils.isBlank(email) ? "NoValue" : email);
        params.put("mobile", StringUtils.isBlank(phone) ? "NoValue" : phone);
        return this.getSqlSession().selectOne(this.getStatement("getAppflyer"), params);
    }

    @Override
    public Integer getChatterRating(String chatterUserCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", chatterUserCode);
        return (Integer) this.getSqlSession().selectOne(this.getStatement("getChatterRating"), params);
    }

    @Override
    public int updateChannel(String afid, String channel) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("afid", afid);
        params.put("channel", channel);
        return this.getSqlSession().update(this.getStatement("updateChannel"), params);
    }

    @Override
    public int updateAdChannel(String adid, String channel) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("adid", adid);
        params.put("channel", channel);
        return this.getSqlSession().update(this.getStatement("updateAdChannel"), params);
    }

    @Override
    public int userBatchOffline() {
        return this.getSqlSession().update(this.getStatement("userBatchOffline"));
    }

    @Override
    public int updateChatterRating(String userCode, Integer chatterRating) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("chatterRating", chatterRating);
        return this.getSqlSession().update(this.getStatement("updateChatterRating"), params);
    }


    @Override
    public int onlineToOffLine(Integer userOnlineToOfflineValue) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userOnlineToOfflineValue", userOnlineToOfflineValue);
        return this.getSqlSession().update(this.getStatement("onlineToOffLine"), params);
    }

    @Override
    public int onlineToOffLineV2(Integer userOnlineToOfflineValue, List<String> keepOnlineUserCodes) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userOnlineToOfflineValue", userOnlineToOfflineValue);
        params.put("keepOnlineUserCodes", keepOnlineUserCodes);
        return this.getSqlSession().update(this.getStatement("onlineToOffLineV2"), params);
    }

    @Override
    public int onlineToOffLineChatter(Integer userOnlineToOfflineValue) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userOnlineToOfflineValue", userOnlineToOfflineValue);
        return this.getSqlSession().update(this.getStatement("onlineToOffLineChatter"), params);
    }

    @Override
    public int onlineToOffLineModel(Integer userOnlineToOfflineValue) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userOnlineToOfflineValue", userOnlineToOfflineValue);
        return this.getSqlSession().update(this.getStatement("onlineToOffLineModel"), params);
    }

    @Override
    public int updateAllCmOnline() {
        return this.getSqlSession().update(this.getStatement("updateAllCmOnline"));
    }

    @Override
    public List<UserDBO> getUserLimitByRegisterDate(Date registerDate) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("registerDate", registerDate);
        return this.getSqlSession().selectList(this.getStatement("getUserLimitByRegisterDate"), params);
    }

    @Override
    public List<UserEntity> listUsersLatestDayAdjust() {
        return this.getSqlSession().selectList(this.getStatement("listUsersLatestDayAdjust"));
    }

    @Override
    public List<UserEntity> listUsersLatestDayFromAppflyers() {
        return this.getSqlSession().selectList(this.getStatement("listUsersLatestDayFromAppflyers"));
    }

    @Override
    public List<String> getTrafficWLMUsers(String userCode, int limitNum) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("limitNum", limitNum);
        return this.getSqlSession().selectList(this.getStatement("getTrafficWLMUsers"), params);
    }

    @Override
    public String getTrafficLBIssueUsers(String userCode) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        return this.getSqlSession().selectOne(this.getStatement("getTrafficLBIssueUsers"), params);
    }

    @Override
    public UserEntity getUserByAdid(String adid) {
        return this.getSqlSession().selectOne(this.getStatement("getUserByAdid"), adid);
    }

    @Override
    public List<String> queryIOSRecommendUsers(int recordNum) {
        return this.getSqlSession().selectList(this.getStatement("queryIOSRecommendUsers"), recordNum);
    }


    @Override
    public List<UserEntity> selectIOSWlmUsers(Page page) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("offset", page.getStartIndex());
        params.put("limit", page.getPageSize());
        return this.getSqlSession().selectList(this.getStatement("selectIOSWlmUsers"), params);
    }

    @Override
    public List<String> getChatterList(int workType) {
        return this.getSqlSession().selectList(this.getStatement("getChatterList"), workType);
    }

    @Override
    public List<UserEntity> getAllChatter() {
        return this.getSqlSession().selectList(this.getStatement("getAllChatter"));
    }

    @Override
    public List<UserEntity> getNormalUser() {
        return this.getSqlSession().selectList(this.getStatement("getNormalUser"));
    }

    @Override
    public UserEntity getChatterInfo(String modelUserCode) {
        return this.getSqlSession().selectOne(this.getStatement("getChatterInfo"), modelUserCode);
    }

    @Override
    public List<String> queryIssueUserPool(String userCode, int lookingFor, List<Integer> poolNums, int limitNum, int filterUserType) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("limitNum", limitNum);
        params.put("poolNums", poolNums);
        // 性向如果为未知，查询全部用户数据
        if (GenderEnum.UNKNOWN.getType() != lookingFor) {
            params.put("lookingFor", lookingFor);
        }
        // [meboo-v3.1.3] 加白账号只展示model数据，流量池过滤空model即可
        if (filterUserType == 3) {
            params.put("filterUserType", 5);
        }
        return this.getSqlSession().selectList(this.getStatement("queryIssueUserPool"), params);
    }

    @Override
    public List<IssueUserPoolEntity> queryIssueUserPoolV2(String userCode, int lookingFor, List<Integer> poolNums, int limitNum, int filterUserType) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("limitNum", limitNum);
        params.put("poolNums", poolNums);
        // 性向如果为未知，查询全部用户数据
        if (GenderEnum.UNKNOWN.getType() != lookingFor) {
            params.put("lookingFor", lookingFor);
        }
        // [meboo-v3.1.3] 加白账号只展示model数据 流量里面选择空model即可
        if (filterUserType == 3) {
            params.put("filterUserType", 5);
        }
        return this.getSqlSession().selectList(this.getStatement("queryIssueUserPoolV2"), params);
    }

    @Override
    public List<IssueUserPoolEntity> queryIssueUserPoolV3(String userCode,String customerCode, int lookingFor, List<Integer> poolNums, int limitNum, int filterUserType) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("customerCode", customerCode);
        params.put("limitNum", limitNum);
        params.put("poolNums", poolNums);
        // 性向如果为未知，查询全部用户数据
        if (GenderEnum.UNKNOWN.getType() != lookingFor) {
            params.put("lookingFor", lookingFor);
        }
        // [meboo-v3.1.3] 加白账号只展示model数据，流量池过滤空model即可
        if (filterUserType == 3) {
            params.put("filterUserType", 5);
        }


        logger.info("==queryIssueUserPoolV3  ==,params:{}", JsonStream.serialize(params));

        return this.getSqlSession().selectList(this.getStatement("queryIssueUserPoolV3"), params);
    }


    @Override
    public List<IssueUserPoolEntity> queryIssueUserPoolV4(String userCode, String customerCode, Integer lookingFor, List<Integer> poolNums, int limitNum, int filterUserType, Integer gender) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("customerCode", customerCode);
        params.put("limitNum", limitNum);
        params.put("poolNums", poolNums);
        // 性向如果为未知，查询全部用户数据
        if (lookingFor != null && GenderEnum.UNKNOWN.getType() != lookingFor) {
            params.put("lookingFor", lookingFor);
        }
        // [meboo-v3.1.3] 加白账号只展示model数据，流量池过滤空model即可
        if (filterUserType == 3) {
            params.put("filterUserType", 5);
        }

        if (gender != null) {
            params.put("gender", gender);
        }
        return this.getSqlSession().selectList(this.getStatement("queryIssueUserPoolV4"), params);
    }

    @Override
    public String queryLBIssueUserPool(String userCode, List<Integer> poolNums) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("poolNums", poolNums);
        return this.getSqlSession().selectOne(this.getStatement("queryLBIssueUserPool"), params);
    }

    @Override
    public String queryLBIssueUserPool2(String userCode, List<Integer> poolNums) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("poolNums", poolNums);
        return this.getSqlSession().selectOne(this.getStatement("queryLBIssueUserPool2"), params);
    }

    @Override
    public String queryLBIssueUserPool3(String userCode, String customerCode, List<Integer> poolNums) {
        Map<String, Object> params = Maps.newHashMap();
        params.put("userCode", userCode);
        params.put("customerCode", customerCode);
        params.put("poolNums", poolNums);
        return this.getSqlSession().selectOne(this.getStatement("queryLBIssueUserPool3"), params);
    }

    @Override
    public int repairRegisterDateIfRegisterIsNull() {
        return this.getSqlSession().update(this.getStatement("repairRegisterDateIfRegisterIsNull"));
    }

    @Override
    public List<UserEntity> listAllWhiteUsers(List<String> whiteUsers) {
        if (CollectionUtils.isEmpty(whiteUsers)) {
            return Lists.newArrayList();
        }
        Map<String, Object> params = Maps.newHashMap();
        params.put("list", whiteUsers);
        return this.getSqlSession().selectList(this.getStatement("listAllWhiteUsers"), params);
    }

    @Override
    public Integer batchUpdateUserOnlineStatus(List<String> userCodes, Integer onlineStatus, String onlineTimeStamp) {
        if (CollectionUtils.isEmpty(userCodes)) {
            return 0;
        }
        Map<String, Object> params = Maps.newHashMap();
        params.put("list", userCodes);
        params.put("onlineStatus", onlineStatus);
        params.put("onlineTimeStamp", onlineTimeStamp);
        return this.getSqlSession().update(this.getStatement("batchUpdateUserOnlineStatus"), params);
    }

    @Override
    public List<UserEntity> getUserByAfid(String afid) {
        if (com.fqgj.common.utils.StringUtils.isEmpty(afid)) {
            return null;
        }
        Map<String, Object> params = Maps.newHashMap();
        params.put("afid", afid);
        return this.getSqlSession().selectList(this.getStatement("getUserByAfid"), params);
    }
}